  	//压缩图片
	function imageComporess (Originalfile, quality, callback) { 
	  var file
	  var fileType
	  var url
	  var compressedImageDataURL
	  var compressedImageBlob
	  var compressSuccess = false
	  var contentType // 从 canvas.toDataURL 的结果中获取的 contentType
	   
	   
	 	var fileName
	 	if(Originalfile.value!=""){
	    file = Originalfile.files[0]
	    fileName = file.name
	    fileType = file.type || 'image/' + fileName.substr(fileName.lastIndexOf('.') + 1)
	   
	    if (url) {
	      window.URL.revokeObjectURL(url)
	    }
	    url = window.URL.createObjectURL(file)
	   
	   	/*
	    * HTMLCanvasElement.toDataURL() 不支持传入的类型非“image/png”，
	    * 但是值以“data:image/png”开头的类型。
	    */   
	   
	    var sourceImage = new Image();
	    sourceImage.src=url;
	    sourceImage.onload=function(e){	
		    var canvas = document.createElement("canvas");
		    var context = canvas.getContext('2d')	
		    if (!isCanvasBlank(canvas)) {
		      context.clearRect(0, 0, canvas.width, canvas.height)
		    }
		    canvas.width = sourceImage.naturalWidth
		    canvas.height = sourceImage.naturalHeight
		    context.drawImage(sourceImage, 0, 0)	    
		    var mimeType = fileType || 'image/png'
		   compressedImageDataURL = canvas.toDataURL(mimeType, quality / 100)
		   compressedImageBlob = dataURL2Blob(compressedImageDataURL)
		    var data=new Object;
		   if (compressedImageBlob.size > file.size) {//压缩后的图片大于原来的图片
		      // Compressed file size > Original file size
		      //console.log(compressedImageBlob.size + ' > ' + file.size)
		     	
		     readBlobAsDataURL(file, function (dataurl){
			      data.base64url=dataurl;
			      data.name=file.name;
		     	 data.compress=compressSuccess;
		     	 data.width=sourceImage.naturalWidth;
		     	 data.height=sourceImage.naturalHeight;
		     	  console.log('图片原来大小：'+file.size+ '图片的宽高：'+sourceImage.naturalWidth  +'x'+sourceImage.naturalHeight+ data.compress==true?'压缩':'不压缩')
				console.log('新图片大小：'+compressedImageBlob.size+ '图片的宽高：'+canvas.width  +'x'+ canvas.height+ data.compress==true?'压缩':'不压缩')
		   
		     	 callback(data);
				});	
		    
		      return
		    }
		   compressSuccess=true;
		    data.base64url=compressedImageDataURL;
		     data.name=file.name;
		    data.compress=compressSuccess;
		    data.width=sourceImage.naturalWidth;
		    data.height=sourceImage.naturalHeight;
		     console.log('图片原来大小：'+file.size+ '图片的宽高：'+sourceImage.naturalWidth  +'x'+sourceImage.naturalHeight+ data.compress==true?'压缩':'不压缩')
			console.log('新图片大小：'+compressedImageBlob.size+ '图片的宽高：'+canvas.width  +'x'+ canvas.height+ data.compress==true?'压缩':'不压缩')
		   
		    callback(data);
	   }
	  }
	}
	 
 
 
 window.URL = window.URL || window.webkitURL

	function isCanvasBlank (canvas) {
	  var blank = document.createElement('canvas')
	  blank.width = canvas.width
	  blank.height = canvas.height
	
	  return canvas.toDataURL() == blank.toDataURL()
	}
	
	function newBlob (data, datatype) {
	  var out
	  try {
	    out = new Blob([data], { type: datatype })
	  } catch (e) {
	    window.BlobBuilder = window.BlobBuilder ||
	    window.WebKitBlobBuilder ||
	    window.MozBlobBuilder ||
	    window.MSBlobBuilder
	
	    if (e.name == 'TypeError' && window.BlobBuilder) {
	      var bb = new BlobBuilder()
	      bb.append(data)
	      out = bb.getBlob(datatype)
	    } else if (e.name == 'InvalidStateError') {
	      out = new Blob([data], { type: datatype })
	    } else {
	      throw new Error('Your browser does not support Blob & BlobBuilder!')
	    }
	  }
	  return out
	}
	
	function dataURL2Blob (dataURI) {
	  var byteStr
	  var intArray
	  var ab
	  var i
	  var mimetype
	  var parts
	
	  parts = dataURI.split(',')
	  parts[1] = parts[1].replace(/\s/g, '')
	
	  if (~parts[0].indexOf('base64')) {
	    byteStr = atob(parts[1])
	  } else {
	    byteStr = decodeURIComponent(parts[1])
	  }
	
	  ab = new ArrayBuffer(byteStr.length)
	  intArray = new Uint8Array(ab)
	
	  for (i = 0; i < byteStr.length; i++) {
	    intArray[i] = byteStr.charCodeAt(i)
	  }
	
	  mimetype = parts[0].split(':')[1].split(';')[0]
	
	  return new newBlob(ab, mimetype)
	}
	
	function readBlobAsDataURL(file, callback) {
	    var reader = new FileReader();
	    reader.onload = function(e) {
	    	callback(e.target.result);
	    };	    
	    reader.readAsDataURL(file);
	}
	
	
	
	


